CQG API Documentation 4.0 - Revised
Frequently Asked Questions
Send Feedback

Glossary Item Box

  1. What model is used in CQG API?

    CQG API has asynchronous nature - i.e., when the user requests some information by calling a method, the requested information is not yet available upon the method’s return. When the requested information becomes available, a corresponding event is fired, which the user application shall catch to receive the requested information.

  2. Why CQG API is asynchronous?

    CQG API triggers information retrieval, which means that some time is needed to collect it.

    If it was synchronous, all calls to CQG API would be hanging until corresponding information was retrieved.

  3. Do I need to use a message loop in my application?

    Since CQG API's nature is asynchronous, you need to use message loop to prevent your application from ending.

  4. Does CQG API 64-bit version exist?
    See CQG API 32-bit and 64-bit versions topic.

  5. Is CQG API thread safe?
    No, it is not. It means that the calling of CQG API methods from different threads without synchronization can lead to undefined behavior. 

  6. Why do I need to handle the DataError event?

    During request processing, errors might occur and the client-side is notified about them with the DataError event. This will have valuable information in many unpredictable situations, such as "CQGIC is not started".

  7. Is it enough to handle the DataError event only? Do I need additional error handling in my code?

    Some of the errors are reported synchronously and COM exceptions are thrown in such cases, which might be caught using error handlers.

  8. Why some events are received with additional parameter of CQGError type?

    If the returned data is somehow incomplete or some error has occurred during the request, the accompanying CQGError will describe what is wrong with it.

  9. I can’t find some order properties in the CQGOrder interface.

    The properties in the CQGOrder interface are limited to the most common and frequently used ones.
    You can access the rest of the available order properties from CQGOrder.CQGOrderProperties collection using the eOrderProperty enumeration as a key.

    Please note that some properties do not apply to all order types. For example, a market order does not have limit price.

  10. Why no CELStarted or DataError events are fired after creating CQGCEL object and calling its StartUp method?

    If you are using CQG API from MS Excel, you need to handle the CQGCEL.IsReady event and pass your current status (which can be obtained through Application.Ready property) to its readyStatus parameter.

    If you are using CQG API not from MS Excel, you need to:

    1. either handle the CQGCEL.IsReady event and pass the eReadyStatus.rsReady to its readyStatus parameter,
    2. or set the CQGCEL.CQGAPIConfig.ReadyStatusCheck property to eReadyStatusCheck.rscOff.
  11. Why I do not get DOM events?

    The default setting for CQGCEL.CQGAPIConfig.DefaultInstrumentSubscriptionLevel is eDataSubscriptionLevel.dsQuotesAndBBA. This means that DOM data will not be fetched by default. If you want to receive DOM values, you need to:

    1. either after subscription, change the CQGInstrument.DataSubscriptionLevel to eDataSubscriptionLevel.dsQuotesAndDOM
    2. or set the CQGCEL.CQGAPIConfig.DefaultInstrumentSubscriptionLevel property to eDataSubscriptionLevel.dsQuotesAndDOM before calling the CQGCEL.StartUp method.
  12. A DataError is received or a COM Error is thrown with the following description:
    "You are not enabled for retrieving data via CQG API. To enable this feature, please call CQG Customer Support."
    What should I do?

    You are trying to use some features of CQG API, which require enablements you currently lack. Please find more information about the enablements in the Quick-Guide section of this document. Then contact the API Support to subscribe to the needed enablements.

  13. Why should I handle the CQGCEL.DataConnectionStatusChanged and CQGCEL.GWConnectionStatusChanged events?

    While you are working with CQG API, you need to monitor the data and gateway connection statuses. In order to work properly, CQG API functionalities require that the corresponding connection is up.

    For example,

    1. to subscribe and retrieve market data for an instrument data connection must be up, which can be monitored by handling the CQGCEL.DataConnectionStatusChanged event.
    2. to place an order and monitor its status or get account status information, you should check the gateway connection to be up by handling the CQGCEL.GWConnectionStatusChanged event.
  14. How can I pass Date values to CQGCEL methods' Variant arguments from Matlab?

    When you need to pass a VT_DATE type input to an ActiveX control method, you can use the MATLAB class COM.date.
    For example:

    d = COM.date(2007,12,21,15,30,05);

    You can use now to set the Value property to a date number:

    d.Value = now;

  15. How many CQGCEL instances can be run simultaneously?

    The maximum number of CQGCEL instances to run simultaneously is limited to ten. When this number is exceeded, the error with code 196 is reported via CQGCEL.DataError event with the following message:

    Cannot start API instance: maximum number of instances is exceeded.

  16. Why does the API memory footprint continuously increase when Ticks are requested with "Current Notify"?

    When you perform a Ticks request with its type set to trtCurrentNotify, all tick updates will be received and added to the already received ticks. (Those ticks can be accessed through CQGCEL.AllTicks.) In the meantime, data being received occupies more and more memory.

    The received ticks collection size can be limited with CQGTicksRequest.Limit property.

    Also, you may consider subscribing to an instrument to receive its real-time data, instead.

  17. Why do I receive extra records when I combine multiple sub expressions in my historical request?

    When you combine sub expressions that have some timescale deviation in one request, up to double the requested number of records may be returned, depending on the coincidence of their timestamps.

    Example:

    For a historical request formulated as following:

    SubExpression1 = Open(DD)

    SubExpression2 = CVLow(DD)

    RangeEnd = -5

    Intraday

    1 min

    The returned records may look like the following:

    Returned record Timestamp Open(DD) CVLow(DD)
    1 10:01 4708 4706
    2 10:01 4706
    3 10:02 4706 4705
    4 10:02 4706
    5 10:03 4707
    6 10:04 4708 4707
    7 10:05 4707

    Here, you need to take into account that the RangeEnd specification has a different meaning for each of the sub expressions as following:

    • For the Open(DD), RangeEnd = -5 means the last five one-minute bars’ Open values will be returned;
    • And for the CVLow(DD), RangeEnd = -5 means the last five constant volume bars’ Low values will be returned.

    Note also, that each sub expression’s total number of returned records is five.

  18. CEL memory usage is growing by time. Is it a memory leak?

    CEL is a single-thread process. It keeps an events queue list and waits for the user application to process an event before it delivers the next one on list. In a scenario where the user application is delaying the processing of events, the queue may get really long—consuming a lot of memory.

    Solution: The event handler should be designed to be as efficient as possible. While for simple procedures (e.g., API samples) it is fine to combine some secondary tasks in the event handler, powerful applications should be designed so that event handling is separated from other functions.

    If you have already made sure that your application’s event handler is not the bottle neck, please report your problem to API Support for further investigation.

  19. There are requests that allow defining time interval for data receiving. For example, CQGTimedBarsRequestCQGRenkoBarsRequest, etc.
    How to request data from specific time in the past to current time with future updates?

    You should set the following properties:

    With these request settings, new bars will be received and updated.

  20. Why CQG IC is shut down automatically if it is connected to some exchanges?

    Some FCMs may enforce session timeout based on a designated period of inactivity for client applications.
    For more information regarding the relevant regulations, please see Guidelines for Reducing and Mitigating Hacking Risks Associated with Internet Trading.

  21. Is there any way to cancel requests? For example, CQGTimedBarsRequestCQGTicksRequest, etc.

    Yes, there is Remove family methods that cancel corresponded requests. For example, RemoveTimedBarsRemoveTicks, etc.

  22. How to login to GW with a demo account?

    Use CQGCEL.GWLogon method with the following argument values: username_ = "DEMO" and password_ = "DEMO".

  23. I want to place orders, but I can't subscribe to instrument because I don't have real-time data, what should I do?
    Use APIConfiguration.NewInstrumentMode and CQGCEL.CreateInstrumentRequest method to subscribe to instrument.